package com.bit.demo.springioc.controller;

import com.bit.demo.springioc.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

@Controller
public class MyController {
//    属性注入
//    @Autowired
//    private UserService userService;

    // 构造器注入
    private UserService userService;
    public MyController(UserService userService) {
        this.userService = userService;
    }

    //setter注入
    @Autowired
    public void setUserService(UserService userService) {
        this.userService = userService;
    }


    public void sayHello(){
        System.out.println("hello world...");
        userService.sayHello();
    }
}
